package com.guigu.www.service.imp;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guigu.www.mapper.AuthorizationMapper;
import com.guigu.www.pojo.Authorization;
import com.guigu.www.service.AuthorizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AuthorizationServiceImpl extends ServiceImpl<AuthorizationMapper, Authorization> implements AuthorizationService {
    @Autowired
    AuthorizationMapper mapper;
    @Override
    public List<Authorization> querybyauall(int roleid) {
        //查询权限
        List<Authorization> authorizations=mapper.querybyauall();
        //查询当前角色的权限
        List<Authorization> list=mapper.querybyroleid(roleid);
        //判断
        for(Authorization authorization : authorizations){
            if(list.contains(authorization.getAuid())){
                authorization.setCheck(true);
            }
        }

        return authorizations;
    }
}
